<?php

/**
 * 新增专辑封面模板
 * 
 * @copyright xinwei
 * @since 2012-03-23
 */

include_once($_SERVER["DOCUMENT_ROOT"] . "/core/inc.php");
include_once($_SERVER["DOCUMENT_ROOT"] . "/core/admin.inc.php");
include_once($_SERVER["DOCUMENT_ROOT"] . "/include/foodv2/inc.php");

$g_cgival = array();
$g_pro = array();
$g_show = array();


function check_cgi_pro()
{
	global $g_cgival, $g_pro, $g_show;
	
	//模板名称
	cgi::get($g_cgival["template_id"], "template_id", "");
	$g_cgival["template_id"] = intval($g_cgival["template_id"]);
	if(!$g_cgival["template_id"])
	{
		throw new Exception("请选择模板。");
	}
}

function get_data()
{
	global $g_cgival, $g_pro, $g_show;
	
	$db = new db_food_album_cover_template();
	$user_db = new db_food_user();
	//$class_db = new db_food_album_class();
	
	// 拿到当前站点的site_id
	$site_id = admin::admin_get_user_site_id();
	
	// 获取专辑模板信息
	$info = $db->admin_get_food_album_cover_template_by_ids($g_cgival["template_id"]);
	$data['template_info'] = $info[0]; 


	$g_show["data"] = $data;	

	//当前参数输出到页面	
	$g_show['args'] = $g_cgival;
}

$g_show["error"] = 0;
$g_show["errmsg"] = '';
try
{
	admin_check_login();
// 	admin_check_user_priv("foodv2/album_cover_template_add.php");
	
	check_cgi_pro();
	get_data();
}
catch(Exception $e)
{
	$g_show["error"] = 1;
	$g_show["errmsg"] = $e->getMessage();
}

show_pro();
exit;


function show_pro()
{
	global $g_cgival, $g_pro, $g_show;
	if(isset($_GET['debug']))
		print_r($g_show);
	$smarty = p_get_smarty ();
	$smarty->assign ( 'g_show', $g_show );
	$smarty->display ( "foodv2/album/album_cover_template_add.html" );
}

?>